package com.kakarote.bi.common.utils;

import cn.hutool.core.util.StrUtil;

import java.util.HashMap;
import java.util.Map;

/**
 * @description:
 * @company: 卡卡罗特软件科技有限公司
 * @author: zyh
 * @date: 2022/6/16 9:57
 * @version: @Version: V1.0
 */
public class LanguageFieldUtil {

    public static Map<String, String> getFieldNameKeyMap(String keyName, String fieldName) {
        Map<String, String> keyMap = new HashMap<>();
        keyMap.put(keyName, getFieldNameKey(fieldName));
        return keyMap;
    }

    public static String getFieldName(String fieldName) {
        if (StrUtil.isNotBlank(fieldName)) {
            fieldName = StrUtil.toCamelCase(fieldName);
        }
        if (StrUtil.isNotBlank(fieldName) && fieldName.endsWith("Id")) {
            fieldName = fieldName.substring(0, fieldName.lastIndexOf("Id")).concat("Name");
        }
        if (StrUtil.isNotBlank(fieldName) && fieldName.endsWith("Ids")) {
            fieldName = fieldName.substring(0, fieldName.lastIndexOf("Ids")).concat("Names");
        }
        return fieldName;
    }

    public static String getFieldNameKey(String fieldName) {
        fieldName = getFieldName(fieldName);
        return fieldName;
    }

}
